<template>
  <div class="login_container">
    <div class="login_box">
      <div class="login_img">
        <img src="../assets/img/faker.jpeg">
      </div>

        <el-form :model="loginForm" :rules="rules" ref="loginForm" size="small" class="login_form">
          <el-form-item  prop="username">
            <el-input v-model="loginForm.username" prefix-icon="el-icon-user" ></el-input>
          </el-form-item>
          <el-form-item  prop="password">
            <el-input v-model="loginForm.password" prefix-icon="el-icon-lock" type="password"></el-input>
          </el-form-item>
          <div class="verifyBox">
            <el-form-item  prop="verifyCode">
              <el-input v-model="loginForm.verifyCode" prefix-icon="el-icon-phone" type="password" class="verify_code"></el-input>
              <img src="../assets/img/yzm.jpeg" class="verify_img">
            </el-form-item>
          </div>

          <el-form-item>
            <el-button type="primary" @click="submitForm('loginForm')">登录</el-button>
            <el-button @click="resetForm('loginForm')">重置</el-button>
          </el-form-item>
        </el-form>

    </div>
  </div>

</template>

<script>
export default {
  name: "Login",
  data(){
    return {
      loginForm: {
        username: '',
        password: '',
        verifyCode:''
      },
      rules: {
        name: [
          {required: true, message: '请输入活动名称', trigger: 'blur'},
          {min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur'}
        ],
      },
    }

  },
  methods:{
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
         this.$router.push("/main")
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }


}
</script>

<style lang="less" scoped>
.login_container{
  width: 100%;
  height: 100%;
  background-color: aqua;
  .login_box{
    width: 450px;
    height: 300px;
    background-color: #FFFFFF;
    border-radius: 3px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
    .login_img{
      width: 130px;
      height: 130px;
      border: 1px solid #2c3e50;
      border-radius: 50%;
      box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
      margin: -65px auto;
      background-color: #FFFFFF;
      img{
        width: 100%;
        height: 100%;
        border-radius: 50%;
      }

    }
    .login_form{
      position: absolute;
      bottom: 0;
      width: 100%;
      padding: 0 20px;
      box-sizing: border-box;
      .verifyBox{
        display: flex;
        .verify_code{
          width: 60%;
          justify-content: left;
        }
        .verify_img{
          width: 40%;
          height: 30px;
          justify-content: flex-end;
          margin-bottom: -10px;
        }
      }

    }

  }
}
</style>
